<layout name="layout"/>

<div class="main-div">


    <form name="main_form" class="form-x" id="myform" method="POST" action="__SELF__" enctype="multipart/form-data">
        <input type="hidden" name="id" value="<?php echo $data['id']; ?>"/>
        <div class="form-group">
            <div class="label">
                <label>代理名称：</label>
            </div>
            <div class="field">
                <input type="text" class="input w50" value="<?php echo $data['agentname']; ?>" name="agentname"
                       data-validate="required:代理名称"/>
                <div class="tips"></div>
            </div>
        </div>
        <div class="form-group">
            <div class="label">
                <label>手机号：</label>
            </div>
            <div class="field">
                <input type="text" class="input w50" onblur="isPoneAvailable(this.value)"
                       value="<?php echo $data['phone']; ?>" name="phone"
                       data-validate="required:手机号"/>
                <div class="tips"></div>
            </div>
        </div>
        <div class="form-group">
            <div class="label">
                <label>QQ号：</label>
            </div>
            <div class="field">
                <input type="text" class="input w50" value="<?php echo $data['qq']; ?>" name="qq"
                       data-validate="required:QQ号"/>
                <div class="tips"></div>
            </div>
        </div>
        <div class="form-group">
            <div class="label">
                <label>注册时间：</label>
            </div>
            <div class="field">
                <span class="input w50" style="border: none;"><?php echo date('Y-m-d H:i:s',$data['retime']) ?></span>

                <div class="tips"></div>
            </div>
        </div>
        <div class="form-group">
            <div class="label">
                <label>微信号：</label>
            </div>
            <div class="field">
                <input type="text" class="input w50" value="<?php echo $data['wx']; ?>" name="wx"
                       data-validate="required:微信号"/>
                <div class="tips"></div>
            </div>
        </div>
        <div class="form-group">
            <div class="label">
                <label>提现名称：</label>
            </div>
            <div class="field">
                <input type="text" class="input w50" value="<?php echo $data['txname']; ?>" name="txname"
                       data-validate="required:提现名称"/>
                <div class="tips"></div>
            </div>
        </div>
        <div class="form-group">
            <div class="label">
                <label>提现费率：</label>
            </div>
            <div class="field">
                <input type="text" class="input w50" value="<?php echo $data['txfl']; ?>" name="txfl"
                       data-validate="required:费率"/>
                <div class="tips"></div>
            </div>
        </div>
        <div class="form-group">
            <div class="label">
                <label>当前域名：</label>
            </div>
            <div class="label">
                <label>  {:$data['domain']}</label>
            </div>

        </div>
        <div class="form-group">

            <div class="label">
                <label>请从以下域名中选择：</label>
            </div>
            <div class="">
                <?php if(!empty($result)):?>
                <select name="domain" class="input" style="width:200px; line-height:17px;">
                    <option value="">请选择域名</option>
                    <foreach name="result" item="v">
                        <option value="{:$v['domainlink']}">{:$v['domainlink']}</option>
                    </foreach>
                </select>
                <?php else:?>
                <div class="label">
                    <label>暂无可用域名，请配置</label>
                </div>
                <?php endif;?>
            </div>
        </div>
        <div class="form-group">
            <div class="label">
                <label></label>
            </div>
            <div class="field">
                <button class="button bg-blue" type="submit"> 提交</button>
                <input type="reset" value="重置" class="button bg-red">
                <input type="button" value="取消" onclick="javascript :history.back(-1)" class="button bg-main">
            </div>
        </div>
    </form>
</div>
<script>
    $(":submit").click(function () {
        var data = $("#myform").serialize();
        if ($("input[name='agentname']").val() == '' || $("input[name='agentname']").val() == undefined) {
            alert('代理名称不能为空');
            return false;
        }

        if ($("input[name='phone']").val() == '' || $("input[name='phone']").val() == undefined) {
            alert('手机号不能为空');
            return false;
        }
        if ($("input[name='txname']").val() == '' || $("input[name='txname']").val() == undefined) {
            alert('提现人名称不能为空');
            return false;
        }
        if ($("select").val() == '' || $("select").val() == undefined) {
            alert('域名不能为空');
            return false;
        }
        $.post("<?php echo U('edit')?>", data, function (res) {

            alert(res.info);
            location.href = res.url;
        })
    })

    function isPoneAvailable(poneInput) {
        var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
        if (!myreg.test(poneInput)) {
            alert('手机号码不正确！');
            return false;
        }
    }
</script>
